package com.freshcity.manager.support
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import com.freshcity.ILayer;
	
	public class UILayer extends Sprite implements ILayer
	{
		public function UILayer()
		{
			super();
			tabChildren = false;
			mouseEnabled = false;
			return;
		}
		
		public function addPopUp(obj:DisplayObject, isCenter:Boolean=false):void
		{
			if (obj && this.contains(obj) == false) 
			{
				this.addChild(obj);
			}
			if(isCenter){
				this.centerPopup(obj);
			}
		}
		
		public function centerPopup(arg1:DisplayObject):void
		{
			arg1.x = (stage.stageWidth - arg1.width) / 2;
			arg1.y = (stage.stageHeight - arg1.height) / 2;
		}
		
		public function setPosition(arg1:DisplayObject, arg2:int, arg3:int):void
		{
			arg1.x = arg2;
			arg1.y = arg3;
			return;
		}
		
		public function isTop(arg1:DisplayObject):Boolean
		{
			if (this.contains(arg1)) 
			{
				return this.getChildIndex(arg1) == (this.numChildren - 1);
			}
			return false;
		}
		
		public function removePopup(arg1:DisplayObject):void
		{
			if (this.contains(arg1)) 
			{
				this.removeChild(arg1);
			}
			return;
		}
		
		public function isPopup(arg1:DisplayObject):Boolean
		{
			return this.contains(arg1);
		}
		
		public function setTop(arg1:DisplayObject):void
		{
			if (this.contains(arg1)) 
			{
				if (this.getChildIndex(arg1) != (this.numChildren - 1)) 
				{
					this.setChildIndex(arg1, (this.numChildren - 1));
				}
			}
			return;
		}
		
		public function resize(arg1:Number, arg2:Number):void
		{
			var loc1:*=null;
			var loc2:*=0;
			while (loc2 < numChildren) 
			{
				loc1 = this.getChildAt(loc2);
				if (loc1 is DisplayObject) 
				{
					loc1.x = loc1.x * arg1;
					loc1.y = loc1.y * arg2;
				}
				++loc2;
			}
			return;
		}

	}
}